--[[
Name: archaeologyJournal
Author: Sonora (The Dragonflight, US Kirin Tor)
Website & SVN: http://wow.curseforge.com/addons/archaeologyjournal/
License: GNU General Public License v3
]]


--Functions that draw stuff.
function archaeologyJournal:injectLogTab()
    
    local smallPos = {'BOTTOMLEFT', ArchaeologyFrame,'BOTTOMRIGHT', -17.5, 17.5}
    local bigPos = {'BOTTOMLEFT', ArchaeologyFrame,'BOTTOMRIGHT', -27.5, 17.5}

    local logTabButton = CreateFrame('Button', nil, ArchaeologyFrame)
    logTabButton:SetHeight(57)
    logTabButton:SetWidth(63)
    logTabButton:SetPoint(unpack(smallPos))
    
    local normalTexture = logTabButton:CreateTexture()
    normalTexture:SetAllPoints(logTabButton)
    normalTexture:SetTexture(self.config.journalButtonSmall)
    normalTexture:SetVertexColor(unpack(self.config.journalButtonColor))
    logTabButton:SetNormalTexture(normalTexture)
    
    local highTexture = logTabButton:CreateTexture()
    highTexture:SetAllPoints(logTabButton)
    highTexture:SetTexture(self.config.journalButtonSmall)
    highTexture:SetVertexColor(1,1,1,0.3)
    highTexture:SetBlendMode("ADD")
    logTabButton:SetHighlightTexture(highTexture)
    
    local textSmallPos = {'RIGHT', logTabButton, 'RIGHT', -40, 0}
    local textBigPos = {'RIGHT', logTabButton, 'RIGHT', -25, 0}
    local fontString = logTabButton:CreateFontString(nil, 'OVERLAY')
    fontString:SetFont(self.config.fontName, 18)
    fontString:SetTextColor(unpack(self.config.fontColor))
    fontString:SetPoint(unpack(textSmallPos))
    fontString:SetText("J")
    
    self.logShown = false
    logTabButton:SetScript('OnClick',
        function()
            if self.logShown == false then
                PlaySound("igSpellBookOpen")
        
                local archFrame = ArchaeologyFrame
        
                --Copied from Blizzard UI dump (any IP concerns here?)
		archFrame["tab"..ARCHAEOLOGY_COMPLETED_TAB]:GetNormalTexture():SetSize(48, 57)
		archFrame["tab"..ARCHAEOLOGY_COMPLETED_TAB]:GetHighlightTexture():SetSize(48, 57)
		archFrame["tab"..ARCHAEOLOGY_COMPLETED_TAB]:GetNormalTexture():SetTexCoord(0.31250000, 0.40625000, 0.56250000, 0.78515625)
		archFrame["tab"..ARCHAEOLOGY_COMPLETED_TAB]:GetHighlightTexture():SetTexCoord(0.31250000, 0.40625000, 0.56250000, 0.78515625)
        
    		archFrame["tab"..ARCHAEOLOGY_SUMMARY_TAB]:GetNormalTexture():SetSize(48, 57)
		archFrame["tab"..ARCHAEOLOGY_SUMMARY_TAB]:GetHighlightTexture():SetSize(48, 57)
		archFrame["tab"..ARCHAEOLOGY_SUMMARY_TAB]:GetNormalTexture():SetTexCoord(0.21484375, 0.30859375, 0.56250000, 0.78515625)
		archFrame["tab"..ARCHAEOLOGY_SUMMARY_TAB]:GetHighlightTexture():SetTexCoord(0.21484375, 0.30859375, 0.56250000, 0.78515625)
		archFrame["tab"..ARCHAEOLOGY_SUMMARY_TAB].factionIcon:SetPoint("CENTER", -13, 0)
        
        	archFrame.summaryPage:Hide()
                archFrame.completedPage:Hide()
                archFrame.artifactPage:Hide()
                archFrame.helpPage:Hide()
                archFrame.rankBar:Hide()
                archFrame.raceFilterDropDown:Hide()
                --End copy.
        
                archFrame.bgLeft:SetTexture("Interface\\AddOns\\ArchaeologyJournal\\media\\bookBackground.tga")
                archFrame.bgRight:SetTexture("Interface\\Archeology\\Arch-BookCompletedRight")
                
                logTabButton:SetPoint(unpack(bigPos))
                fontString:SetPoint(unpack(textBigPos))
                normalTexture:SetTexture(self.config.journalButtonBig)
                highTexture:SetTexture(self.config.journalButtonBig)
                self.logShown = true
                self:showJournal()
            end
        end
    )
    
    logTabButton:SetScript('OnEnter',
        function()
            GameTooltip:SetOwner(logTabButton, "ANCHOR_BOTTOMRIGHT")
            GameTooltip:SetText("Journal")
        end
    )
    
    logTabButton:SetScript('OnLeave',
        function()
            GameTooltip:Hide()
        end
    )
    
    local function smallifyButton()
        logTabButton:SetPoint(unpack(smallPos))
        fontString:SetPoint(unpack(textSmallPos))
        highTexture:SetTexture(self.config.journalButtonSmall)
        normalTexture:SetTexture(self.config.journalButtonSmall)
        self.logShown = false
    end
    
    self:SecureHookScript(ArchaeologyFrameSummarytButton, 'OnClick', smallifyButton)
    self:SecureHookScript(ArchaeologyFrameCompletedButton, 'OnClick', smallifyButton)
    self:SecureHookScript(ArchaeologyFrameInfoButton, 'OnClick', smallifyButton)
    
    logTabButton:Show()
    self.logTabButton = logTabButton
    
end

function archaeologyJournal:showJournal()
    
end

